<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?php echo C('site_name');?></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">

<script type="text/javascript" src="<?php echo STATICS;?>/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<?php echo STATICS;?>/js/jquery.form.min.js"></script>
<script type="text/javascript" src="<?php echo STATICS;?>/layui/lay/dest/layui.all.js"></script>
<script type="text/javascript" src="<?php echo STATICS;?>/js/regExp.js"></script>
<script type="text/javascript" src="<?php echo RES;?>/js/common.js"></script>

<link rel="stylesheet" href="<?php echo STATICS;?>/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="<?php echo STATICS;?>/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo RES;?>/css/global.css" media="all">
<link rel="stylesheet" href="<?php echo RES;?>/css/uploadProgress.css" media="all">

</head>
<body>


<div class="layui-layout layui-layout-admin">
	<div class="layui-header header header-demo">
		<div class="layui-main">
			<div class="admin-login-box">
				<a class="logo" style="left: 0;" href="<?php echo U('Index/index');?>">
					<span style="font-size: 22px;">后台管理</span>
				</a>
				<div class="admin-side-toggle">
					<i class="fa fa-bars" aria-hidden="true"></i>
				</div>
				<div class="admin-top-date">
					今天是：<?php echo (date("Y年m月d日",$date)); ?>，上次登录：<?php echo (date("Y年m月d日 H:i:s",$loginInfo["loginTime"])); ?>，IP：<?php echo ($loginInfo["loginIP"]); ?>
				</div>
			</div>
			<ul class="layui-nav">
				<li class="layui-nav-item">
					<a href="javascript:;" onclick="clearcache();";>清除缓存</a>
				</li>
				<li class="layui-nav-item">
					<a href="<?php echo C('site_url');?>" target="_blank">浏览网站</a>
				</li>
				<li class="layui-nav-item">
					<a href="javascript:;" class="admin-header-user">
						<img src="<?php echo RES;?>/image/face.jpg" style="width: 40px; height: 40px; border-radius: 100%;" />
						<span><?php echo ($admin["username"]); ?></span>
					</a>
					<dl class="layui-nav-child">
						<dd>
							<a href="javascript:;" onclick="openModel('<?php echo U("User/password");?>','修改密码','500px','350px');"><i class="fa fa-user-circle" aria-hidden="true"></i> 修改密码</a>
						</dd>
						<dd>
							<a href="<?php echo U('Login/signout');?>"><i class="fa fa-sign-out" aria-hidden="true"></i> 注销</a>
						</dd>
					</dl>
				</li>
			</ul>
		</div>
	</div>

	<div class="layui-side layui-bg-black" id="admin-side">
		<div class="layui-side-scroll" id="admin-navbar-side" lay-filter="side"></div>
	</div>

	<div class="layui-body" style="bottom: 0;border-left: solid 2px #1AA094;" id="admin-body">
		<div class="layui-tab admin-nav-card layui-tab-brief" lay-filter="admin-tab">
			<ul class="layui-tab-title">
				<li class="layui-this">
					<i class="fa fa-dashboard" aria-hidden="true"></i>
					<cite>控制面板</cite>
				</li>
			</ul>
			<div class="layui-tab-content" style="min-height: 150px; padding: 5px 0 0 0;">
				<div class="layui-tab-item layui-show">
					<iframe src="<?php echo U('Index/main');?>"></iframe>
				</div>
			</div>
		</div>
	</div>
	
	<div class="layui-footer footer footer-demo">
		<div class="layui-main">
			<p>2017 &copy;
				<?php echo C('site_name');?> 版权所有
			</p>
		</div>
	</div>
	<div class="site-tree-mobile layui-hide">
		<i class="layui-icon">&#xe602;</i>
	</div>
	<div class="site-mobile-shade"></div>
	<script>
		layui.config({
			base: '<?php echo STATICS;?>/layui/modules/'
		}).use(['navbar'], function() {
			var element = layui.element(),
				$ = layui.jquery,
				layer = layui.layer,
				navbar = layui.navbar();

			//navbar.render();
			//iframe自适应
			$(window).on('resize', function() {
				var $content = $('.admin-nav-card .layui-tab-content');
				$content.height($(this).height() - 147);
				$content.find('iframe').each(function() {
					$(this).height($content.height());
				});
			}).resize();
			//设置navbar
			navbar.set({
				elem: '#admin-navbar-side',
				url: '<?php echo U('Index/nav');?>'
			});
			//渲染navbar
			navbar.render();
			var $body = $('.admin-nav-card');
			var $tabs = $body.children('ul.layui-tab-title');
			var $contents = $body.children('div.layui-tab-content');
			var tabFilter = 'admin-tab';
			//监听点击事件
			navbar.on('click(side)', function(data) {
				var href = data.field.href;
				if(href === undefined || href === '') {
					return;
				}
				var iframe = '<iframe src="' + href + '"></iframe>';
				var html = '<cite>'+data.elem.find("cite").html()+'</cite>';
				var count = 0;
				var tabIndex;
				//console.log($tabs);
				$tabs.find('li').each(function(i, e) {
					var $cite = $(this).children('cite');
					if($cite.text() === data.elem.find('cite').text()) {
						count++;
						tabIndex = i;
					};
				});
				//tab不存在
				if(count === 0) {
					//添加删除样式
					//html += '<i class="layui-icon layui-unselect layui-tab-close">&#x1006;</i>';
					html += '<i class="fa fa-close layui-tab-close"></i>';
					//添加tab
					element.tabAdd(tabFilter, {
						title: html,
						content: iframe
					});
					//iframe 自适应
					var $content = $('.admin-nav-card .layui-tab-content');
					$content.find('iframe').each(function() {
						$(this).height($content.height());
					});
					//绑定关闭事件
					$tabs = $body.children('ul.layui-tab-title');
					var $li = $tabs.find('li');
					$li.eq($li.length - 1).children('i.layui-tab-close').on('click', function() {
						element.tabDelete(tabFilter, $(this).parent('li').index()).init();
					});
					//获取焦点
					element.tabChange(tabFilter, $li.length - 1);

				} else {
					//切换tab
					element.tabChange(tabFilter, tabIndex);
				}
			});

			$('.admin-side-toggle').on('click', function() {
				console.log($('#admin-side').width());
				console.log($('#admin-body').css('left'));
				var sideWidth = $('#admin-side').width();
				if(sideWidth === 200) {
					$('#admin-side').width(0);
					$('#admin-body').css('left', '0');
				} else {
					$('#admin-side').width(200);
					$('#admin-body').css('left', '200px');
				}

			});

			//手机设备的简单适配
			var treeMobile = $('.site-tree-mobile'),
				shadeMobile = $('.site-mobile-shade');
			treeMobile.on('click', function() {
				$('body').addClass('site-mobile');
			});
			shadeMobile.on('click', function() {
				$('body').removeClass('site-mobile');
			});
		});
	</script>
</div>

</body>
</html>